<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TTMath: ttmath::History&lt; ValueType &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="ttmath_logo_for_doxygen_doc.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">TTMath
   &#160;<span id="projectnumber">0.9.4_prerelease_2019-07-31</span>
   </div>
   <div id="projectbrief">&nbsp;C++ bignum library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacettmath.html">ttmath</a></li><li class="navelem"><a class="el" href="classttmath_1_1_history.html">History</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">ttmath::History&lt; ValueType &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a25f0a380eb1133ef7b9446dbd0a75299"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classttmath_1_1_history.html#a25f0a380eb1133ef7b9446dbd0a75299">History</a> ()</td></tr>
<tr class="separator:a25f0a380eb1133ef7b9446dbd0a75299"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6c4276c2b03be7f6e05dd2fe4edab737"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classttmath_1_1_history.html#a6c4276c2b03be7f6e05dd2fe4edab737">History</a> (typename buffer_type::size_type new_size)</td></tr>
<tr class="separator:a6c4276c2b03be7f6e05dd2fe4edab737"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1bf4725865cfb4f9cd5df86e0bcacd38"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classttmath_1_1_history.html#a1bf4725865cfb4f9cd5df86e0bcacd38">Add</a> (const ValueType &amp;key, const ValueType &amp;value, <a class="el" href="namespacettmath.html#af99599ccaf4dc05cc3a74277f9579942">ErrorCode</a> err)</td></tr>
<tr class="separator:a1bf4725865cfb4f9cd5df86e0bcacd38"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3e39816d5a57a0f510aa01fc0cf4bc7e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classttmath_1_1_history.html#a3e39816d5a57a0f510aa01fc0cf4bc7e">Get</a> (const ValueType &amp;key, ValueType &amp;value, <a class="el" href="namespacettmath.html#af99599ccaf4dc05cc3a74277f9579942">ErrorCode</a> &amp;err)</td></tr>
<tr class="separator:a3e39816d5a57a0f510aa01fc0cf4bc7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adfcd26d5a29b9d3f7a77b333419db57c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classttmath_1_1_history.html#adfcd26d5a29b9d3f7a77b333419db57c">Remove</a> (const ValueType &amp;key)</td></tr>
<tr class="separator:adfcd26d5a29b9d3f7a77b333419db57c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;class ValueType&gt;<br />
class ttmath::History&lt; ValueType &gt;</h3>

<p>objects of the class <a class="el" href="classttmath_1_1_history.html">History</a> are used to keep values in functions which take a lot of time during calculating, for instance in the function Factorial(x)</p>
<p>it means that when we're calculating e.g. Factorial(1000) and the Factorial finds that we have calculated it before, the value (result) is taken from the history </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00605">605</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a25f0a380eb1133ef7b9446dbd0a75299"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a25f0a380eb1133ef7b9446dbd0a75299">&#9670;&nbsp;</a></span>History() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classttmath_1_1_history.html">ttmath::History</a>&lt; ValueType &gt;::<a class="el" href="classttmath_1_1_history.html">History</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>default constructor default max size of the <a class="el" href="classttmath_1_1_history.html">History</a>'s container is 15 items </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00634">634</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00635"></a><span class="lineno">  635</span>&#160;    {</div><div class="line"><a name="l00636"></a><span class="lineno">  636</span>&#160;        buffer_max_size = 15;</div><div class="line"><a name="l00637"></a><span class="lineno">  637</span>&#160;    }</div></div><!-- fragment -->
</div>
</div>
<a id="a6c4276c2b03be7f6e05dd2fe4edab737"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6c4276c2b03be7f6e05dd2fe4edab737">&#9670;&nbsp;</a></span>History() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classttmath_1_1_history.html">ttmath::History</a>&lt; ValueType &gt;::<a class="el" href="classttmath_1_1_history.html">History</a> </td>
          <td>(</td>
          <td class="paramtype">typename buffer_type::size_type&#160;</td>
          <td class="paramname"><em>new_size</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>a constructor which takes another value of the max size of the <a class="el" href="classttmath_1_1_history.html">History</a>'s container </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00644">644</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00645"></a><span class="lineno">  645</span>&#160;    {</div><div class="line"><a name="l00646"></a><span class="lineno">  646</span>&#160;        buffer_max_size = new_size;</div><div class="line"><a name="l00647"></a><span class="lineno">  647</span>&#160;    }</div></div><!-- fragment -->
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a1bf4725865cfb4f9cd5df86e0bcacd38"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1bf4725865cfb4f9cd5df86e0bcacd38">&#9670;&nbsp;</a></span>Add()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classttmath_1_1_history.html">ttmath::History</a>&lt; ValueType &gt;::Add </td>
          <td>(</td>
          <td class="paramtype">const ValueType &amp;&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const ValueType &amp;&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespacettmath.html#af99599ccaf4dc05cc3a74277f9579942">ErrorCode</a>&#160;</td>
          <td class="paramname"><em>err</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>this method adds one item into the <a class="el" href="classttmath_1_1_history.html">History</a> if the size of the container is greater than buffer_max_size the first item will be removed </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00655">655</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00656"></a><span class="lineno">  656</span>&#160;    {</div><div class="line"><a name="l00657"></a><span class="lineno">  657</span>&#160;        Item item;</div><div class="line"><a name="l00658"></a><span class="lineno">  658</span>&#160;        item.key   = key;</div><div class="line"><a name="l00659"></a><span class="lineno">  659</span>&#160;        item.value = value;</div><div class="line"><a name="l00660"></a><span class="lineno">  660</span>&#160;        item.err   = err;</div><div class="line"><a name="l00661"></a><span class="lineno">  661</span>&#160;</div><div class="line"><a name="l00662"></a><span class="lineno">  662</span>&#160;        buffer.insert( buffer.end(), item );</div><div class="line"><a name="l00663"></a><span class="lineno">  663</span>&#160;</div><div class="line"><a name="l00664"></a><span class="lineno">  664</span>&#160;        <span class="keywordflow">if</span>( buffer.size() &gt; buffer_max_size )</div><div class="line"><a name="l00665"></a><span class="lineno">  665</span>&#160;            buffer.erase(buffer.begin());</div><div class="line"><a name="l00666"></a><span class="lineno">  666</span>&#160;    }</div></div><!-- fragment -->
</div>
</div>
<a id="a3e39816d5a57a0f510aa01fc0cf4bc7e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3e39816d5a57a0f510aa01fc0cf4bc7e">&#9670;&nbsp;</a></span>Get()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classttmath_1_1_history.html">ttmath::History</a>&lt; ValueType &gt;::Get </td>
          <td>(</td>
          <td class="paramtype">const ValueType &amp;&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">ValueType &amp;&#160;</td>
          <td class="paramname"><em>value</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespacettmath.html#af99599ccaf4dc05cc3a74277f9579942">ErrorCode</a> &amp;&#160;</td>
          <td class="paramname"><em>err</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>this method checks whether we have an item which has the key equal 'key'</p>
<p>if there's such item the method sets the 'value' and the 'err' and returns true otherwise it returns false and 'value' and 'err' remain unchanged </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00676">676</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00677"></a><span class="lineno">  677</span>&#160;    {</div><div class="line"><a name="l00678"></a><span class="lineno">  678</span>&#160;        <span class="keyword">typename</span> buffer_type::iterator i = buffer.begin();</div><div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;</div><div class="line"><a name="l00680"></a><span class="lineno">  680</span>&#160;        <span class="keywordflow">for</span>( ; i != buffer.end() ; ++i )</div><div class="line"><a name="l00681"></a><span class="lineno">  681</span>&#160;        {</div><div class="line"><a name="l00682"></a><span class="lineno">  682</span>&#160;            <span class="keywordflow">if</span>( i-&gt;key == key )</div><div class="line"><a name="l00683"></a><span class="lineno">  683</span>&#160;            {</div><div class="line"><a name="l00684"></a><span class="lineno">  684</span>&#160;                value = i-&gt;value;</div><div class="line"><a name="l00685"></a><span class="lineno">  685</span>&#160;                err   = i-&gt;err;</div><div class="line"><a name="l00686"></a><span class="lineno">  686</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00687"></a><span class="lineno">  687</span>&#160;            }</div><div class="line"><a name="l00688"></a><span class="lineno">  688</span>&#160;        }</div><div class="line"><a name="l00689"></a><span class="lineno">  689</span>&#160;</div><div class="line"><a name="l00690"></a><span class="lineno">  690</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00691"></a><span class="lineno">  691</span>&#160;    }</div></div><!-- fragment -->
</div>
</div>
<a id="adfcd26d5a29b9d3f7a77b333419db57c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adfcd26d5a29b9d3f7a77b333419db57c">&#9670;&nbsp;</a></span>Remove()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class ValueType&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classttmath_1_1_history.html">ttmath::History</a>&lt; ValueType &gt;::Remove </td>
          <td>(</td>
          <td class="paramtype">const ValueType &amp;&#160;</td>
          <td class="paramname"><em>key</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>this methods deletes an item</p>
<p>we assume that there is only one item with the 'key' (this methods removes the first one) </p>

<p class="definition">Definition at line <a class="el" href="ttmathobjects_8h_source.html#l00700">700</a> of file <a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a>.</p>
<div class="fragment"><div class="line"><a name="l00701"></a><span class="lineno">  701</span>&#160;    {</div><div class="line"><a name="l00702"></a><span class="lineno">  702</span>&#160;        <span class="keyword">typename</span> buffer_type::iterator i = buffer.begin();</div><div class="line"><a name="l00703"></a><span class="lineno">  703</span>&#160;</div><div class="line"><a name="l00704"></a><span class="lineno">  704</span>&#160;        <span class="keywordflow">for</span>( ; i != buffer.end() ; ++i )</div><div class="line"><a name="l00705"></a><span class="lineno">  705</span>&#160;        {</div><div class="line"><a name="l00706"></a><span class="lineno">  706</span>&#160;            <span class="keywordflow">if</span>( i-&gt;key == key )</div><div class="line"><a name="l00707"></a><span class="lineno">  707</span>&#160;            {</div><div class="line"><a name="l00708"></a><span class="lineno">  708</span>&#160;                buffer.erase(i);</div><div class="line"><a name="l00709"></a><span class="lineno">  709</span>&#160;                <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00710"></a><span class="lineno">  710</span>&#160;            }</div><div class="line"><a name="l00711"></a><span class="lineno">  711</span>&#160;        }</div><div class="line"><a name="l00712"></a><span class="lineno">  712</span>&#160;</div><div class="line"><a name="l00713"></a><span class="lineno">  713</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00714"></a><span class="lineno">  714</span>&#160;    }</div></div><!-- fragment -->
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="ttmathobjects_8h_source.html">ttmathobjects.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
